<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page isErrorPage="true"%>
<jsp:directive.page import="com.toncen.samepms.util.ErrorUtils"/>
<jsp:directive.page import="com.toncen.samepms.common.ComitConstant"/>
<jsp:directive.page import="com.toncen.samepms.system.dao.ErrorLoggerDao"/>
<jsp:directive.page import="com.toncen.samepms.system.domain.ErrorLogger"/>
<%
	String errorPath = request.getContextPath();
	String errorBasePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + errorPath + "/";
	response.setStatus(403);//标记为没有权限	
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>错误提示</title>
		<%@include file="/share/header.jsp"%>
		<STYLE type="text/css">
			.font-12-000000-height25 {
				font-size: 12px;
				line-height: 25px;
				color: #000000;
				margin-left:25px;
			}	
			.font-12-ff0000 {
				font-size: 12px;
				color: #FF0000;
			}	
			.button {
				border: 1px solid #7DAECC;
				height: 2em;
				font-size: 12px;
				clip:     rect(auto auto auto auto);
				padding-right: 3px;
				padding-left: 3px;
				text-align:center;
				text-valign:middle;
				cursor: hand;
			}						
		</STYLE>		
	</head>
	<%
		out.println("<script>alert(\"很抱歉，您要访问的页面出现了小错误，我们会将此信息发送给系统管理员!\");</script>");	
		Throwable throwable = null;
		try {//保存错误信息
			throwable = ErrorUtils.getThowable(request, response, exception);
			ErrorLoggerDao errorInfoDao = new ErrorLoggerDao();
			ErrorLogger errorLogger=ErrorUtils.builderErrorLogger(request, response, throwable);
			errorInfoDao.add(errorLogger);
		} catch (Throwable t) {
			t.printStackTrace();
			out.println("<script>alert(\"保存错误日志信息出错，请与系统管理员联系！\");</script>");
		}
	%>
	<body>
		<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td align="center" valign="middle">
					<table width="304" height="176" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td align="center" valign="middle" background="<%=errorBasePath%>/error/error.jpg">
								<table width="250" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td width="96" height="109">
											&nbsp;
										</td>
										<td width="164" class="font-12-000000-height25">
											<span class="font-12-ff0000">&nbsp;&nbsp;&nbsp;&nbsp;很抱歉，您要访问的页面出现了小错误，我们会将此信息发送给系统管理员!</span>
											<br>如果您要继续访问其他页面，请选择以下操作：
										</td>
									</tr>
								</table>
								<input type="button" class="button" value="返回首页" onclick="top.document.location.replace('<%=errorBasePath + "/" + ErrorUtils.getIndexURL(request, response)%>')"	accesskey="f">
								<input type="button" class="button"  value="返回上一页" onclick="history.go(-1)" accesskey="r">
								<input type="button" class="button"  value="关闭此窗口" onclick="if(confirm('你确实要关闭当前窗口？')){ try{top.opener=null;  top.open('','_self');	}catch(e){}	top.close(); }" accesskey="c">						
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>	
		<div>
		<%
		if (ComitConstant.isDeveloperMode()&&throwable!=null) {//开发者模式，则在页面和控制台打印出堆栈信息
		%>
		<fieldset>
			<legend>
				错误堆栈信息:
			</legend>
			<%
			throwable.printStackTrace();
			%>
			<%=ErrorUtils.getStackTrace(throwable)%>
		</fieldset>
		<%
		}
		%>			
		</div>	
		<%
			ErrorUtils.releaseError(request, response);//释放错误信息相关资源
			%>
		<script>
			
		</script>
	</body>
</html>
